package com.tmall.tmall.mapper;

import com.tmall.tmall.pojo.Address;
import com.tmall.tmall.pojo.AddressRt;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ShippingAddressMapper {
    List<AddressRt> page(String name, String tel, String address, Integer uid);

    @Insert("insert into address_book (uid, name, tel, address, create_time) value (#{uid},#{name},#{tel},#{address},#{createTime})")
    void insert(Address address);

    void update(Address address);

    @Select("select " +
            "ab.id as id," +
            "u.name as username," +
            "ab.name as name," +
            "ab.tel as tel," +
            "ab.address as address," +
            "ab.create_time as create_time" +
            " from address_book as ab,user as u " +
            " where " +
            " ab.delete_at is null " +
            "and" +
            " u.delete_at is null" +
            " and " +
            " ab.uid=u.id " +
            " and ab.uid=#{id}")
    List<AddressRt> getById(Integer id);
}
